﻿namespace card_makerWeb.Service;
public class ImageStateService
{
    public string ImageId { get; private set; } = "draggableImage";
    public bool IsDragging { get; set; } = false;
    public double OriginalX { get; set; } = 0;
    public double OriginalY { get; set; } = 0;
    public double CurrentX { get; set; } = 0;
    public double CurrentY { get; set; } = 0;
    public double Scale { get; set; } = 1;
    public double XPosition { get; set; } = 0;
    public double YPosition { get; set; } = 0;

    public event Action OnChange;

    public void UpdateDragging(bool isDragging)
    {
        IsDragging = isDragging;
        NotifyStateChanged();
    }

    public void UpdatePosition(double x, double y)
    {
        CurrentX = x;
        CurrentY = y;
        NotifyStateChanged();
    }

    public void UpdateScale(double newScale)
    {
        Scale = newScale;
        NotifyStateChanged();
    }

    private void NotifyStateChanged() => OnChange?.Invoke();
}
